<template>
  <div class="app-container">

    <!-- 查询和其他操作 -->
    <div class="filter-container">
      <el-input v-model="listQuery.name" clearable class="filter-item" style="width: 200px;"
        :placeholder="$t('Pleae_enter_coupon_title')" />
      <el-option v-for="type in typeOptions" :key="type.value" :label="type.label" :value="type.value" />
      <el-select v-model="listQuery.lossBearing" clearable class="filter-item" style="width: 200px;"
        :placeholder="$t('损耗承受单位')">
        <el-option v-for="type in lossBearingOptions" :key="type.value" :label="type.label" :value="type.value" />
      </el-select>

      <el-select v-model="listQuery.ranges" clearable class="filter-item" style="width: 200px;"
        :placeholder="$t('使用范围')">
        <el-option v-for="type in rangesOptions" :key="type.value" :label="type.label" :value="type.value" />
      </el-select>

      <el-select v-model="listQuery.areaLimit" clearable class="filter-item" style="width: 200px;"
        :placeholder="$t('区域限制')">
        <el-option v-for="type in areaLimitOptions" :key="type.value" :label="type.label" :value="type.value" />
      </el-select>

      <el-select v-model="listQuery.discountType" clearable class="filter-item" style="width: 200px;"
        :placeholder="$t('折扣类型')">
        <el-option v-for="type in discountTypeOptions" :key="type.value" :label="type.label" :value="type.value" />
      </el-select>

      <el-option v-for="type in typeOptions" :key="type.value" :label="type.label" :value="type.value" />
      <el-select v-model="listQuery.status" clearable style="width: 200px" class="filter-item"
        :placeholder="$t('Please_enter_coupon_status')">
        <el-option v-for="type in statusOptions" :key="type.value" :label="type.label" :value="type.value" />
      </el-select>
      <el-button class="filter-item" type="info" v-permission="['GET /admin/p/coupon_entity_index']"
        icon="el-icon-search" @click="handleFilter">{{ $t('Search') }}</el-button>
      <el-button v-permission="['GET /admin/p/coupon_entity_add']" class="filter-item" type="info" plain1 icon="el-icon-circle-plus"
                 @click="handleCreate">{{ $t('Add') }}</el-button>
      <!--      <el-button :loading="downloadLoading" class="filter-item" type="primary" icon="el-icon-download" @click="handleDownload">{{$t('Find')}}</el-button>-->
    </div>

    <!-- 查询结果 -->
    <el-table v-loading="listLoading" :data="list" :element-loading-text="$t('Searching')" border fit
      highlight-current-row>
      <el-table-column type="index" :index="getIndex" width="50"></el-table-column>

      <el-table-column align="center" :label="$t('Coupon_ID')" prop="id" sortable />

      <el-table-column align="center" :label="$t('Coupon_name')" prop="name" />

      <el-table-column align="center" :label="$t('Lowest_spending_value')" prop="min">
        <template slot-scope="scope">{{ $t('Full') }}{{ scope.row.min }}{{ $t('Dollars') }}
          {{ $t('Lowest_spending_value') }}</template>
      </el-table-column>

      <el-table-column align="center" :label="$t('折扣类型')" prop="discountType">
        <template slot-scope="scope">
          <el-tag>
            {{ scope.row.discountType == 1 ? $t('满减') : $t('折扣') }}
          </el-tag>
        </template>
      </el-table-column>

      <el-table-column align="center" :label="$t('Discount_price')" prop="discount">
        <template slot-scope="scope">
          <span v-if="scope.row.discountType == 1">
            {{ $t('Discount') }}{{ scope.row.discount }}{{ $t('Dollars') }}
          </span>
          <span v-else>
            {{ $t('折扣') }}{{ scope.row.discountRate }}{{ $t('%') }}
          </span>
        </template>
      </el-table-column>

      <el-table-column align="center" :label="$t('商品限制范围')" prop="ranges" width="130">
        <template slot-scope="scope">
          <el-tag effect="plain1" v-for="item in filterRanges(scope.row.ranges)" :key="item">
            {{ $t(item) }}
          </el-tag>
        </template>
      </el-table-column>

      <el-table-column align="center" :label="$t('Merchandise_usage_limits')" prop="goodsType">
        <template slot-scope="scope">{{ formatGoodsType(scope.row.goodsType) }}</template>
      </el-table-column>

      <!--      区域限制，损耗承受单位，开始日期，结束日期，发放数量-->
      <el-table-column align="center" :label="$t('区域限制')" prop="areaLimit">
        <template slot-scope="scope">{{ formatAreaLimit(scope.row.areaLimit) }}</template>
      </el-table-column>

      <el-table-column align="center" :label="$t('损耗承受单位')" prop="lossBearing">
        <template slot-scope="scope">{{ formatLossBearing(scope.row.lossBearing) }}</template>
      </el-table-column>

      <el-table-column align="center" :label="$t('发放数量')" prop="total">
        <template slot-scope="scope">{{ scope.row.total }}</template>
      </el-table-column>

      <el-table-column align="center" :label="$t('状态')" prop="status">
        <template slot-scope="scope">{{ formatStatus(scope.row.status) }}</template>
      </el-table-column>

      <el-table-column align="center" :label="$t('Operate')" width="400" class-name="small-padding fixed-width">
        <template slot="header" slot-scope="{row}">
          {{$t('Operate')}}
          <i class="el-icon-setting"style="color: #d35e32"></i>
        </template>
        <template slot-scope="scope">
          <el-button icon="el-icon-view" v-permission="['GET /admin/p/coupon_entity_detail']" plain1 size="mini"
            @click="handleDetail(scope.row)">{{ $t('Details') }}</el-button>
          <el-button icon="el-icon-edit" v-permission="['GET /admin/p/coupon_entity_edit']" size="mini"
            v-show="scope.row.status != 1" @click="handleUpdate(scope.row)">{{ $t('Edit') }}</el-button>
          <el-button  icon="el-icon-s-promotion" plain1 v-permission="['GET /admin/p/coupon_entity_status']" type="success"  size="mini"
            @click="handleStatus(scope.row)">{{ formateStatus(scope.row.status) }}</el-button>
          <el-button icon="el-icon-delete" plain1 v-show="scope.row.status != 1" v-permission="['GET /admin/p/coupon_entity_delete']" type="danger"
            size="mini" @click="handleDelete(scope.row)">{{ $t('Delete') }}</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit"
      @pagination="getList" />

  </div>
</template>

<style>
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.avatar-uploader .el-upload:hover {
  border-color: #20a0ff;
}

.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 120px;
  height: 120px;
  line-height: 120px;
  text-align: center;
}

.avatar {
  width: 120px;
  height: 120px;
  display: block;
}
</style>

<script>
import { listCoupon, createCoupon, updateCoupon, deleteCoupon, changeCouponStatus } from '@/api/coupon'
import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
import { listGoods } from '@/api/goods'
import { listCategory } from '@/api/category'
import { listLocationRegion } from '@/api/region'
import { uploadPath } from '../../api/storage'
import { getToken } from '../../utils/auth'


export default {
  name: 'entityCoupon',
  components: { Pagination },
  filters: {},
  data() {
    const defaultTypeOptions = [
      {
        label: this.$t('实体优惠券'),
        value: 2
      }
    ]

    const defaultLossBearingOptions = [
      {
        label: this.$t('总部'),
        value: 0
      },
      {
        label: this.$t('门店'),
        value: 1
      },
    ]

    const defaultAreaLimitOptions = [
      {
        label: this.$t('不限地区使用'),
        value: 0
      },
      {
        label: this.$t('限地区使用'),
        value: 1
      },
    ]

    const defaultStatusOptions = [
      {
        label: this.$t('新增'),
        value: 0
      },
      {
        label: this.$t('已上架'),
        value: 1
      },
      {
        label: this.$t('已下架'),
        value: 2
      }
    ]

    const defaultDiscountTypeOptions = [
      {
        label: this.$t('满减'),
        value: 1
      },
      {
        label: this.$t('折扣'),
        value: 2
      }
    ]

    const defaultRangesOptions = [
      {
        label: this.$t('通用'),
        value: 0
      },
      {
        label: this.$t('APP'),
        value: 1
      },
      {
        label: this.$t('POS'),
        value: 2
      },
      {
        label: this.$t('网站'),
        value: 3
      },
    ]

    const validateDiscount = (rule, value, callback) => {
      let discountType = this.dataForm.discountType
      if (discountType == 1 && !value) {
        return callback(new Error(this.$t('满减金额不能为空')));
      }

      callback();
    }

    const validateDiscountRate = (rule, value, callback) => {
      let discountType = this.dataForm.discountType
      if (discountType == 2 && !value) {
        return callback(new Error(this.$t('百分比不能为空')));
      }

      callback();
    }

    const validateDays = (rule, value, callback) => {
      let timeType = this.dataForm.timeType
      if (timeType == 0 && !value) {
        return callback(new Error(this.$t('相对天数不能为空')));
      }

      callback();
    }

    const validateStartTime = (rule, value, callback) => {
      let timeType = this.dataForm.timeType
      if (timeType == 1 && !value) {
        return callback(new Error(this.$t('开始时间不能为空')));
      }

      callback();
    }

    const validateEndTime = (rule, value, callback) => {
      let timeType = this.dataForm.timeType
      if (timeType == 1 && !value) {
        return callback(new Error(this.$t('结束时间不能为空')));
      }

      callback();
    }

    const validateGoodsValue = (rule, value, callback) => {
      let goodsType = this.dataForm.goodsType
      if (goodsType == 1 && value.length == 0) {
        return callback(new Error(this.$t('商品分类不能为空')));
      }
      callback();
    }

    const validateRegions = (rule, value, callback) => {
      let regions = this.dataForm.regions;
      if (regions && regions.length == 0) {
        return callback(new Error(this.$t('区域不能为空')));
      }
    }

    return {
      uploadPath,
      isLevelMember: false,
      isMoneyMember: false,
      defaultTypeOptions,
      defaultStatusOptions,
      typeOptions: Object.assign({}, defaultTypeOptions),
      lossBearingOptions: Object.assign({}, defaultLossBearingOptions),
      areaLimitOptions: Object.assign({}, defaultAreaLimitOptions),
      statusOptions: Object.assign({}, defaultStatusOptions),
      rangesOptions: Object.assign({}, defaultRangesOptions),
      discountTypeOptions: Object.assign({}, defaultDiscountTypeOptions),
      list: [],
      total: 0,
      listLoading: true,
      listQuery: {
        lossBearing: undefined,
        page: 1,
        limit: 20,
        name: undefined,
        type: 2,
        status: undefined,
        sort: 'add_time',
        order: 'desc',
        isExpired: false
      },
      goodsList: [],
      listGoodsQuery: {
        page: 1,
        limit: 10000,
        sort: 'add_time',
        order: 'desc'
      },
      dataForm: {
        selectGoods: [],
        id: undefined,
        name: undefined,
        desc: undefined,
        tag: undefined,
        total: 1,
        discount: 1,
        discountType: 1,
        discountRate: 100,
        min: 1,
        ranges: 0,
        limit: 1,
        type: 3,
        status: 0,
        goodsType: 0,
        goodsValue: [],
        regions: [],
        levelMemberType: [],
        moneyMemberType: [],
        useLimit: '',
        useLimitNum: 1,
        areaLimit: 0,
        lossBearing: 0,
        timeType: 1,
        days: 1,
        startTime: null,
        endTime: null,
        userLevel: [0],
        promotionOnly: false,
        country: '',
        province: '',
        city: '',
        pictureUrl: '',
        surplus: 0,
      },
      dialogFormVisible: false,
      dialogStatus: '',
      textMap: {
        update: this.$t('Edit'),
        create: this.$t('Create')
      },
      provinces: [],
      citys: [],
      countys: [],
      countrys: [],
      rules: {
        name: [
          { required: true, message: this.$t('Coupon_title_cannot_be_empty'), trigger: 'blur' }
        ],
        discount: [
          { validator: validateDiscount, trigger: 'blur' }
        ],
        discountRate: [
          { validator: validateDiscountRate, trigger: 'blur' }
        ],
        min: [
          { required: true, trigger: 'blur' }
        ],
        limit: [
          { required: true, trigger: 'blur' }
        ],
        total: [
          { required: true, trigger: 'blur' }
        ],
        useLimit: [
          { required: true, trigger: 'change', message: this.$t('用户限制类型不能为空') }
        ],
        useLimitNum: [
          { required: true, trigger: 'blur' }
        ],
        timeType: [
          { required: true, trigger: 'blur' }
        ],
        days: [
          { validator: validateDays, trigger: 'blur' }
        ],
        startTime: [
          { validator: validateStartTime, trigger: 'blur' }
        ],
        endTime: [
          { validator: validateEndTime, trigger: 'blur' }
        ],
        goodsValue: [
          { validator: validateGoodsValue, trigger: 'blur' }
        ],
        regions: [
          { validator: validateRegions, trigger: 'blur' }
        ]
        // country: [
        //   // { required: true, message: this.$t('国家不能为空'), trigger: 'blur' },
        //   { validator: validateCountry, trigger: 'change' }
        // ],
        // province: [
        //   // { required: true, message: this.$t('省份不能为空'), trigger: 'blur' },
        //   { validator: validateProvince, trigger: 'change' }
        // ],
        // city: [
        //   // { required: true, message: this.$t('城市不能为空'), trigger: 'blur' },
        //   { validator: validateCity, trigger: 'change' }
        // ],
      },
      downloadLoading: false,
      categories: [],
      locations: [],
      props: { multiple: true, value: 'id', label: 'name', emitPath: false },
      regionProps: { multiple: true, value: 'id', label: 'nameEn', emitPath: false },
      options: [{
        value: 0,
        label: this.$t('每年')
      }, {
        value: 1,
        label: this.$t('每月')
      }, {
        value: 2,
        label: this.$t('每周')
      }],
      levelMember: [],
      moneyMember: []
    }
  },
  created() {
    this.getList()
    this.getGoods()
    this.getCategories()
    this.getLocations()
  },
  methods: {
    formatType(type) {
      for (let i = 0; i < this.defaultTypeOptions.length; i++) {
        if (type === this.defaultTypeOptions[i].value) {
          return this.defaultTypeOptions[i].label
        }
      }
      return ''
    },
    formatGoodsType(goodsType) {
      if (goodsType === 0) {
        return this.$t('Usable_in_any_situation')
      } else if (goodsType === 1) {
        return this.$t('Select_category')
      } else {
        return this.$t('Select_merchandise')
      }
    },
    formatLossBearing(lossBearing) {
      if (lossBearing === 0) {
        return this.$t('总部')
      } else {
        return this.$t('门店')
      }
    },
    formatAreaLimit(areaLimit) {
      if (areaLimit === 0) {
        return this.$t('不限区域')
      } else {
        return this.$t('限制区域')
      }
    },

    formatStatus(status) {
      if (status === 0) {
        return this.$t('新增')
      } else if (status === 1) {
        return this.$t('已上架')
      } else {
        return this.$t('已下架')
      }
    },
    getGoods() {
      this.listLoading = true
      listGoods(this.listGoodsQuery).then(response => {
        this.goodsList = response.data.data.list.map(goods => {
          return {
            label: goods.name,
            key: goods.id
          }
        })
      }).catch(() => {
        this.list = []
      })
    },
    getList() {
      this.listLoading = true
      listCoupon(this.listQuery)
        .then(response => {
          this.list = response.data.data.list
          this.total = response.data.data.total
          this.listLoading = false
        })
        .catch(() => {
          this.list = []
          this.total = 0
          this.listLoading = false
        })
    },
    handleFilter() {
      this.listQuery.page = 1
      this.getList()
    },
    resetForm() {
      this.dataForm = {
        selectGoods: [],
        id: undefined,
        name: undefined,
        desc: undefined,
        tag: undefined,
        total: 1,
        discount: 1,
        discountType: 1,
        discountRate: 100,
        min: 1,
        ranges: [],
        limit: 1,
        type: 3,
        status: 0,
        goodsType: 0,
        goodsValue: [],
        levelMemberType: [],
        moneyMemberType: [],
        useLimit: '',
        useLimitNum: 1,
        areaLimit: 0,
        lossBearing: 0,
        timeType: 1,
        days: 1,
        startTime: null,
        endTime: null,
        userLevel: [0],
        promotionOnly: false,
        pictureUrl: '',
        surplus: 0,
      }
    },
    handleCreate() {
      this.resetForm()
      this.dialogStatus = 'create'
      this.dialogFormVisible = true
      this.$nextTick(() => {
        this.$refs['dataForm'].clearValidate()
      })
      this.$router.push({ name: 'entityCouponCreate', query: { dataForm: this.dataForm, dialogStatus: this.dialogStatus } })

    },
    handleUpdate(row) {
      this.dataForm = Object.assign({}, row)
      this.dataForm.selectGoods = this.dataForm.goodsValue
      this.dialogStatus = 'update'
      this.dialogFormVisible = true
      this.$nextTick(() => {
        if (this.dataForm.days === 0) {
          this.dataForm.daysType = 1
        } else {
          this.dataForm.daysType = 0
        }
        this.$refs['dataForm'].clearValidate()
        this.getCategories()
      })

      this.$router.push({ name: 'entityCouponCreate', query: { dataForm: this.dataForm, dialogStatus: this.dialogStatus } })
    },
    updateData() {
      this.$refs['dataForm'].validate(valid => {
        if (valid) {
          if (this.dataForm.discountType == 2) {
            let p = [];
            this.dataForm.goodsValue.forEach(goodsId => {
              p.push(goodsId[2])
            })
            this.dataForm.goodsValue = p;
          }
          if (this.dataForm.selectGoods.length != 0 && this.dataForm.goodsType === 2) {
            this.dataForm.goodsValue = [];
            for (let i = 0; i < this.dataForm.selectGoods.length; i++) {
              this.dataForm.goodsValue[i] = this.dataForm.selectGoods[i]
            }
          }
          this.dataForm.surplus = this.dataForm.total
          updateCoupon(this.dataForm)
            .then(() => {
              for (const v of this.list) {
                if (v.id === this.dataForm.id) {
                  const index = this.list.indexOf(v)
                  this.list.splice(index, 1, this.dataForm)
                  break
                }
              }
              this.dialogFormVisible = false
              this.$notify.success({
                title: this.$t('Success!'),
                message: this.$t('Coupon_update_successful')
              })
            })
            .catch(response => {
              this.$notify.error({
                title: this.$t('Failed'),
                message: this.$t(response.data.errmsg)
              })
            })
        }
      })
    },
    handleDelete(row) {
      this.$confirm(this.$t('Confirm_Delete?'), this.$t('Hint'), {
        confirmButtonText: this.$t('Confirm'),
        cancelButtonText: this.$t('Cancel'),
        type: 'warning'
      }).then(() => {
        this.doDelete(row)
      });
    },
    doDelete(row) {
      deleteCoupon(row)
        .then(response => {
          this.$notify.success({
            title: this.$t('Success!'),
            message: this.$t('Coupon_deleted')
          })
          const index = this.list.indexOf(row)
          this.list.splice(index, 1)
        })
        .catch(response => {
          this.$notify.error({
            title: this.$t('Failed'),
            message: this.$t(response.data.errmsg)
          })
        })
    },
    handleDetail(row) {
      this.$router.push({ path: '/coupon/entityCouponDetail', query: { id: row.id } })
    },
    filterGoodsMethod(query, item) {
      return item.label.indexOf(query) > -1
    },
    nolimit() {
      if (this.dataForm.userLevel && this.dataForm.userLevel.indexOf(0) == this.dataForm.userLevel.length - 1) {
        this.dataForm.userLevel = [0]
      } else if (this.dataForm.userLevel.indexOf(0) >= 0) {
        _.forEach(this.dataForm.userLevel, (item, index) => {
          if (item == 0) {
            this.dataForm.userLevel.splice(index, 1)
          }
        })
      }
    },
    handleDownload() {
      this.downloadLoading = true
      import('@/vendor/Export2Excel').then(excel => {
        const tHeader = [
          this.$t('优惠券ID'),
          this.$t('名称'),
          this.$t('内容'),
          this.$t('标签'),
          this.$t('最低消费'),
          this.$t('减免金额'),
          this.$t('每人限领'),
          this.$t('优惠券数量'),
          this.$t('使用限制'),
          this.$t('使用限制数量')
        ]
        const filterVal = [
          'id',
          'name',
          'desc',
          'tag',
          'min',
          'discount',
          'limit',
          'total',
          'useLimit',
          'useLimitNum'
        ]
        excel.export_json_to_excel2(tHeader, this.list, filterVal, this.$t('优惠券信息'))
        this.downloadLoading = false
      })
    },
    getCategories() {
      listCategory().then(response => {
        this.categories = response.data.data.list
        if (this.dataForm.goodsValue && this.dataForm.goodsValue.length > 0) {
          let p = [];
          this.dataForm.goodsValue.forEach(goodsId => {
            this.categories.forEach(category => {
              if (category.children && category.children.length > 0) {
                category.children.forEach(item => {
                  if (item.children && item.children.length > 0) {
                    item.children.forEach(sub => {
                      if (sub.id == goodsId) {
                        let tmp = sub.id;
                        p.push(tmp)
                      }
                    })
                  }
                })
              }
            })
          })
          this.dataForm.goodsValue = p;
        }
      })
    },
    handleChangeType() {
      if (this.dataForm.type == 3) {
        this.dataForm.userLevel = [0]
        this.dataForm.promotionOnly = false
        this.dataForm.timeType = 1
        this.dataForm.goodsType = 0
      }
    },
    getIndex(index) {
      return (index + 1) + (this.listQuery.page - 1) * this.listQuery.limit;
    },
    //校验输入框数字为正整数
    prevent(e) {
      var keynum = window.event ? e.keyCode : e.which;   //获取键盘码
      if (keynum == 189 || keynum == 190 || keynum == 109 || keynum == 110) {
        this.$message.warning(this.$t('禁止输入小数以及负数'))
        e.target.value = ''
      }
    },
    changeNum(num) {
      if (num < 0) {
        this.$message.warning(this.$t('禁止输入小数以及负数'))
        this.dataForm.useLimitNum = 1;
      }
    },
    filterRanges(obj) {
      // if (obj == 0) {
      //   return this.$t("通用")
      // } else if (obj == 1) {
      //   return this.$t("APP")
      // } else if (obj == 2) {
      //   return this.$t("POS")
      // } else {
      //   return this.$t("网站")
      // }
      const arr = [
        '通用',
        'APP',
        'POS',
        '网站',
      ]
      return obj.map(item => arr[item]);
    },
    filterUseLimit(obj) {
      if (obj == 0) {
        return this.$t("每年")
      } else if (obj == 1) {
        return this.$t("每月")
      } else {
        return this.$t("每周")
      }
    },
    getLocations() {
      listLocationRegion().then(response => {
        this.locations = response.data.data.list
        if (this.dataForm.regions && this.dataForm.regions.length > 0) {
          let p = [];
          this.dataForm.regions.forEach(id => {
            this.locations.forEach(region => {
              if (region.children && region.children.length > 0) {
                region.children.forEach(item => {
                  if (item.children && item.children.length > 0) {
                    item.children.forEach(sub => {
                      if (sub.id == id) {
                        let tmp = sub.id;
                        p.push(tmp)
                      }
                    })
                  }
                })
              }
            })
          })
        }
      })

    },
    changeLevelMember(obj) {
      this.isLevelMember = !this.isLevelMember
    },
    changeMoneyMember(obj) {
      this.isMoneyMember = !this.isMoneyMember
    },
    handleStatus(row) {
      this.$confirm(this.$t('是否') + this.$t('改变优惠券状态') + "?", this.$t('提示'), {
        confirmButtonText: this.$t('Confirm'),
        cancelButtonText: this.$t('Cancel'),
        type: 'warning'
      }).then(() => {
        this.doIgnore(row)
      });
    },
    doIgnore(row) {
      let data = {
        id: row.id
      }
      changeCouponStatus(data).then(response => {
        this.$notify.success({
          title: this.$t('Success!'),
          message: this.$t('Success!')
        })
        this.getList()
      }).catch(response => {
        this.$notify.error({
          title: this.$t('Failed'),
          message: this.$t(response.data.errmsg)
        })
      })
    },
    formateStatus(status) {
      if (status == 0) {
        return this.$t('上架')
      } else if (status == 1) {
        return this.$t('下架')
      } else if (status == 2) {
        return this.$t('上架')
      } else {
        return this.$t('Merchandise_removed')
      }
    },
    handleStatistic(row) {
      this.$router.push({ path: '/coupon/entityCouponStatistic', query: { id: row.id } })
    },
    uploadPicUrl: function (response) {
      this.dataForm.pictureUrl = response.data.url
    },
    handleGoodsPicRemove: function () {
      this.dataForm.pictureUrl = undefined
    },
  },

  computed: {
    headers() {
      return {
        'X-Litemall-Admin-Token': getToken()
      }
    }
  }

}
</script>
